<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\select2\Select2;
use yii\helpers\ArrayHelper;
use yii\widgets\Pjax;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\GkyQyhUserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Gky Qyh Users';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="gky-qyh-user-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <div class="col-lg-12 col-md-12">
        <?php
        $form = ActiveForm::begin([
                    'action' => ['index'],
                    'method' => 'get',
                    'options' => ['class' => 'input-group col-md-12'],
                    'fieldConfig' => [
                        'template' => '<div class="col-lg-12 col-md-12">{input}</div>',
                    ]
                ])
        ?>
        <div class="col-lg-4 col-md-4">
            <label style="float: left;margin-top: 5px;">姓名</label>
            <div style="overflow: hidden;">
                <?php
                $datas = app\models\GkyQyhUser::find()->all();
                if ($datas != null) {
                    foreach ($datas as $item) {
                        $source[] = $item->name;
                    }
                } else {
                    $source[] = array();
                }
                echo yii\jui\AutoComplete::widget([
                    'model' => $searchModel,
                    'attribute' => 'name',
                    'options' => ['style' => 'margin-left:10px'],
                    'clientOptions' => [
                        'source' => $source,
                    ],
                ]);
                ?>   
            </div>
        </div>

        <div class="col-lg-6 col-md-6">
            <?= Html::submitButton('查找', ['class' => 'btn btn-primary']) ?>
            <?= Html::a('创建', ['create'], ['class' => 'btn btn-primary']) ?>
            <?= Html::a('同步', ['index', 'isUpdata' => true], ['class' => 'btn btn-primary']) ?>

        </div>

        <div class="row" style="margin: 10px 0 15px 15px;">

        </div>



        <?php ActiveForm::end(); ?>    
        <?php Pjax::begin(); ?>
        <?=
        GridView::widget([
            'dataProvider' => $dataProvider,
            'columns' => [
                //  ['class' => 'yii\grid\SerialColumn'],
//            'id',
                'name',
                'userid',
//            'position',
                'mobile',
                [
                    'attribute' => 'gender',
                    'value' => function($model) {
                        return $model->gender == 1 ? '男' : '女';
                    }
                ],
                'graduate_school',
                'xueli',
                // 'gender',
                // 'weixinid',
                // 'avatar',
                // 'status',
                // 'qyh_id',
                [
                    'class' => 'yii\grid\ActionColumn',
                    'template' => '{view} {update} {delete}',
                    'buttons' => [
                        //view button
                        'view' => function ($url) {
                            return Html::a('<span class="fa fa-search"></span>查看', $url, [
                                        'title' => Yii::t('app', 'View'),
                                            //  'class' => 'btn btn-primary btn-xs',
                            ]);
                        },
                                //update button
                                'update' => function ($url) {
                            return Html::a('<span class="fa fa-search"></span>编辑', $url, [
                                        'title' => Yii::t('app', 'Update'),
                                            // 'class' => 'btn btn-primary btn-xs',
                            ]);
                        },
                                //update button
                                'delete' => function ($url) {
                            return Html::a('<span class="fa fa-search"></span>删除', $url, [
                                        'title' => Yii::t('app', 'Delete'),
                                        'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
                                        'data-method' => 'post',
                                        'data-pjax' => '0',
                                            //  'class' => 'btn btn-primary btn-xs',
                            ]);
                        },
                            ],
                        ],
                    ],
                ]);
                ?>
                <?php Pjax::end(); ?>
    </div>
